package com.soft.javase.ch02.test06;

import java.util.Arrays;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/4/18
 */
public class Order {

    //订单编号
    private String oid;

    //一对一 关联用户信息  双向关联
    private User user;

    //一对多 关联商品信息
    private Goods[] goods;

    //查看订单明细的方法 TODO
    public void showOrderDetail(){
        System.out.println("----------- "+this.oid+" 号订单明细 ----------");
        System.out.println(this.oid+"号订单的所属者是："+user.getName());
        for (Goods good : goods) {
            if(good!=null){
                System.out.println(good);
            }
        }
    }


    public Order() {
    }

    public Order(String oid, User user, Goods[] goods) {
        this.oid = oid;
        this.user = user;
        this.goods = goods;
    }

    /**
     * 获取
     * @return oid
     */
    public String getOid() {
        return oid;
    }

    /**
     * 设置
     * @param oid
     */
    public void setOid(String oid) {
        this.oid = oid;
    }

    /**
     * 获取
     * @return user
     */
    public User getUser() {
        return user;
    }

    /**
     * 设置
     * @param user
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * 获取
     * @return goods
     */
    public Goods[] getGoods() {
        return goods;
    }

    /**
     * 设置
     * @param goods
     */
    public void setGoods(Goods[] goods) {
        this.goods = goods;
    }

    public String toString() {
        return "Order{oid = " + oid + ", user = " + user + ", goods = " + Arrays.toString(goods) + "}";
    }
}
